/*************/
/* Variables */
/*************/

extern boolean lhs_ptr;
extern boolean optimized_while;
extern boolean OpTrace;
extern boolean OpProfileStatement;
extern boolean OpWarning;

extern int code_area_pos;
extern int current_file_no;
extern int current_sequence_extra;
extern int current_sequence_pos;
extern int currentsub;
extern int gline_number;
extern int last_line_number;
extern int lhs_subs1_copy_temp;
extern int seg_extra;
extern int seg_pos;
extern int st_pos;

extern int *current_sequence;

extern int **code_area;

extern long **symtab;

extern char op_result[177];

boolean assignable;

int cg_stack_extra;
int cg_stack_pos;
int lhs_target_temp;
int op_info1;
int op_info2;
int previous_op;

int *cg_stack;


/************/
/* Routines */
/************/

extern void internal_error(char *);


/***********/
/* Defines */
/***********/

#define MININT_VAL -1073741824
#define N_MININT_VAL 1073741824

#define BACKPATCH(x, y) code_area[code_area_pos][x] = y

typedef int *object_ptr;
typedef int object;

struct d {
    double dbl;
    long ref;
};

struct s1 {
    object_ptr base;
    long length;
    long ref;
    long postfill;
};

typedef struct d  *d_ptr;
typedef struct s1 *s1_ptr;

#define IS_ATOM(ob)             (((long)(ob)) >= (long)0xA0000000)
#define IS_SEQUENCE(ob)         (((long)(ob))  < (long)0xA0000000)
#define IS_DBL_OR_SEQUENCE(ob)  (((long)(ob)) < NOVALUE)
#define IS_ATOM_INT(ob)       (((long)(ob)) > NOVALUE)
#define NOVALUE      ((long)0xbfffffffL)

#define MAKE_DBL(x) ( (long) (((unsigned long)(x) >> 3) + (long)0xA0000000) )
#define DBL_PTR(ob) ( (d_ptr)  (((long)(ob)) << 3) )
#define MAKE_SEQ(x) ( (long) (((unsigned long)(x) >> 3) + (long)0x80000000) )
#define SEQ_PTR(ob) ( (s1_ptr) (((long)(ob)) << 3) ) 

#define RefDS(a) ++(DBL_PTR(a)->ref)    
#define RefDSn(a,n) (DBL_PTR(a)->ref += n)  

#define Ref(a) if (IS_DBL_OR_SEQUENCE(a)) { RefDS(a); }
#define Refn(a,n) if (IS_DBL_OR_SEQUENCE(a)) { RefDSn(a,n); }

extern int NewS1(int);

